package interpreter

type tMockSaleOrderService struct {
	items map[int]*SaleOrder
}

func (me *tMockSaleOrderService) Save(it *SaleOrder) {
	me.items[it.ID()] = it
}


func (me *tMockSaleOrderService) Name() string {
	return "sale_order"
}

func (me *tMockSaleOrderService) Filter(filter IRowFilter) []IDataRow {
	rows := make([]IDataRow, 0)
	for _,it := range me.items {
		if filter.Filter(it) {
			rows = append(rows, it)
		}
	}
	return rows
}

func newMockSaleOrderService() ISaleOrderService {
	it := &tMockSaleOrderService{
		items: make(map[int]*SaleOrder, 0),
	}
	MockDatabase.Register(it)
	return it
}

var MockSaleOrderService = newMockSaleOrderService()